Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
How does the loading of an image with "?random=" attached work?

So, I wanted to avoid the cache to see images I'm uploading to this website I'm working on, which I access through localhost.

I hit a handy solution pretty quick:

Attaching to the end of image's path ?random= and a random number generated by Math.floor(). All this with the help of a script.

The HTML showed in the browser:

<img class="gallery_img" src="./uploads/4.jpg?random=172">

Awesome, it works beautifully.

Now, the thing that has been hard to find is an explanation of why and how this actually works.

I mean, 1) how the browser still finds the image in the server with this new path?

Or asked the other way around, 2) how the server handles this ?random=172 attachment and delivers the image asked before that?

If somebody could point me to the right direction I would be grateful.


Solution:

Have a look on what are query parameters.

And if you are dealing with the problem of avoiding the cache, have a look here:

Disable cache for some images

almost 4 years ago · Santiago Trujillo
1 answers
Answer question

0

That is not part of the path, that is a query parameter.

And most of the times the server of images does not care about query parameters, at least not a literally random one, maybe it would support a query parameter called width or size and dynamically generate an image of the correct size. But random is most likely simply discarded and the image is served normally.

almost 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!